# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Stefano Zamprogno <stefano dot zamprogno at gmail dot com>
# Contributor: Chuck Yang <Chuck.Yang@gmail.com>

pkgname=lshw
pkgver=B.02.19.2
pkgrel=5
pkgdesc="A small tool to provide detailed information on the hardware configuration of the machine."
url="https://ezix.org/project/wiki/HardwareLiSter"
license=('GPL')
arch=('loong64' 'x86_64')
depends=('gcc-libs' 'hwdata')
optdepends=('gtk3')
makedepends=('gcc' 'gtk2-compat' 'sqlite')
source=(https://ezix.org/software/files/lshw-$pkgver.tar.gz
        82393aa9b59307a443677df7340a1dd38847a5ef.patch)
sha256sums=('9bb347ac87142339a366a1759ac845e3dbb337ec000aa1b99b50ac6758a80f80'
            '3906335e802387319900a70c7ce575f0f539fce5befd6d37edc74be0d31141df')

prepare() {
  cd "$srcdir"/$pkgname-$pkgver
  sed -i 's|/usr/bin/gtk-lshw|/usr/sbin/gtk-lshw|' src/gui/integration/gtk-lshw.desktop
  sed -i '/^LDFLAGS=$/d' src/core/Makefile src/gui/Makefile
  patch -p1 <../82393aa9b59307a443677df7340a1dd38847a5ef.patch
}

build() {
  cd "$srcdir"/$pkgname-$pkgver
  export VERSION=$pkgver
  make SBINDIR=/usr/bin
  make SBINDIR=/usr/bin gui
}

package() {
  cd "$srcdir"/$pkgname-$pkgver
  make DESTDIR="$pkgdir"/ SBINDIR=/usr/bin install
  make DESTDIR="$pkgdir"/ SBINDIR=/usr/bin install-gui
  install -Dm0644 src/gui/integration/gtk-lshw.desktop "$pkgdir"/usr/share/applications/gtk-lshw.desktop
  install -Dm0644 src/gui/integration/gtk-lshw.pam "$pkgdir"/usr/share/doc/$pkgname/gtk-lshw.pam
  install -Dm0644 src/gui/integration/console.apps "$pkgdir"/usr/share/doc/$pkgname/console.apps
  rm -f "$pkgdir"/usr/share/lshw/{pci,usb}.ids
}
